package sparkStreaming.taxi_hailingCount

import org.apache.spark.sql.SparkSession
import org.apache.spark.streaming.{Seconds, StreamingContext}
import org.apache.spark.{SparkConf, SparkContext}

/**
 * @Author:lixinlei
 * @Date:2021/6/4 7:43
 **/
object Common {

  val BOOTSTRAP = "node101:9092,node102:9092,node103:9092,node104:9092"
  val SERIALIZER_CLASS = "org.apache.kafka.common.serialization.StringSerializer"
  val DESERIALIZER_CLASS = "org.apache.kafka.common.serialization.StringDeserializer"

  val KAFKA_TOPIC_ORACLE = "supermarket"
  val KAFKA_GROUP_ORACLE = "supermarket"

  val MYSQL_USER = "user"
  val MYSQL_PASSWORD = "password"

  val MYSQL_URL_VALUE = "jdbc:mysql://localhost:3306/"
  val MYSQL_DB_SPARK = "taxi"
  val MYSQL_TABLE_DIDI = "taxi_calling_detail"
  val MYSQL_TABLE_DIDICOUNT = "taxi_calling_count"
  val MYSQL_USERNAME_VALUE = "root"
  val MYSQL_PASSWORD_VALUE = "root"

  val MYSQL_URL_VALUE_SPARK = MYSQL_URL_VALUE + MYSQL_DB_SPARK+"?useSSL=false"

  val FOREACHRDD_CHECKPOINT_DIR = "D://resources/updateStateByKey"

  def getSparkSession(master:String,appName:String):SparkSession = {
    SparkSession.builder().master(master).appName(appName).getOrCreate()
  }

  def getStreamingContext(master:String,appName:String):StreamingContext = {
    val conf = new SparkConf()
      .setMaster(master)
      .setAppName(appName)
    new StreamingContext(conf,Seconds(5))
  }



}
